<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>

</head>

<body>
    <div id="app">
        <button-counter></button-counter>
        <button-counter></button-counter>
        <button-counter></button-counter>
    </div>

    <script>
        function outer(){
            var count=0;
            function inner(){
                return count;
            }
            return inner;
        }
        var a=outer();
        console.log(a());

        
        // var data = function () {
        //     return {
        //         count: 0,
        //     }
        // }
        Vue.component("button-counter", {
            // data:data,
            data(){
               return {count:a()};
            },
            created() {
                a();
                console.log("我是组件");
                console.log(this);
            },
            template: `
            <button v-on:click="count++">你点击了{{count}}次</button>
            `
        })

        var app = new Vue({
            el: "#app",
            created() {
                console.log("我是根");
                console.log(this);
            },
        })

    </script>
</body>

</html>